﻿#region directives

using System;

#endregion

namespace ToodleDo
{
    public static class Util
    {
        #region Members

        #endregion

        #region Constructors & Init

        #endregion

        #region Public Methods

        public static DateTime FromUnix(int secs)
        {
            return new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(secs);
        }

        public static int ToUnix(DateTime? date)
        {
            DateTime d = new DateTime();
            if (date != null)
            {
                d = (DateTime) date;
            }
            return (int) (d - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;
        }

        #endregion

        #region #Events & Invokables

        #endregion

        #region Private Methods

        #endregion

        #region EventHandlers

        #endregion
    }
}